<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>GdkDeviceManager</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
<link rel="home" href="index.html" title="GDK 3 参考手册">
<link rel="up" href="reference.html" title="API参考">
<link rel="prev" href="gdk3-GdkScreen.html" title="GdkScreen">
<link rel="next" href="gdk3-GdkDevice.html" title="GdkDevice">
<meta name="generator" content="GTK-Doc V1.17 (XML mode)">
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2">
<tr valign="middle">
<td><a accesskey="p" href="gdk3-GdkScreen.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
<td><a accesskey="u" href="reference.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td>
<td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td>
<th width="100%" align="center">GDK 3 参考手册</th>
<td><a accesskey="n" href="gdk3-GdkDevice.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
</tr>
<tr><td colspan="5" class="shortcuts">
<a href="#gdk3-GdkDeviceManager.synopsis" class="shortcut">Top</a>
                   | 
                  <a href="#gdk3-GdkDeviceManager.description" class="shortcut">Description</a>
</td></tr>
</table>
<div class="refentry">
<a name="gdk3-GdkDeviceManager"></a><div class="titlepage"></div>
<div class="refnamediv"><table width="100%"><tr>
<td valign="top">
<h2><span class="refentrytitle"><a name="gdk3-GdkDeviceManager.top_of_page"></a>GdkDeviceManager</span></h2>
<p>GdkDeviceManager — Functions for handling input devices</p>
</td>
<td valign="top" align="right"></td>
</tr></table></div>
<div class="refsynopsisdiv">
<a name="gdk3-GdkDeviceManager.synopsis"></a><h2>Synopsis</h2>
<pre class="synopsis">
#include &lt;gdk/gdk.h&gt;

                    <a class="link" href="gdk3-GdkDeviceManager.html#GdkDeviceManager" title="GdkDeviceManager">GdkDeviceManager</a>;
<span class="returnvalue">void</span>                <a class="link" href="gdk3-GdkDeviceManager.html#gdk-disable-multidevice" title="gdk_disable_multidevice ()">gdk_disable_multidevice</a>             (<em class="parameter"><code><span class="type">void</span></code></em>);
<a class="link" href="gdk3-GdkDisplay.html#GdkDisplay" title="GdkDisplay"><span class="returnvalue">GdkDisplay</span></a> *        <a class="link" href="gdk3-GdkDeviceManager.html#gdk-device-manager-get-display" title="gdk_device_manager_get_display ()">gdk_device_manager_get_display</a>      (<em class="parameter"><code><a class="link" href="gdk3-GdkDeviceManager.html#GdkDeviceManager" title="GdkDeviceManager"><span class="type">GdkDeviceManager</span></a> *device_manager</code></em>);
<a href="../glib/glib-Doubly-Linked-Lists.html#GList"><span class="returnvalue">GList</span></a> *             <a class="link" href="gdk3-GdkDeviceManager.html#gdk-device-manager-list-devices" title="gdk_device_manager_list_devices ()">gdk_device_manager_list_devices</a>     (<em class="parameter"><code><a class="link" href="gdk3-GdkDeviceManager.html#GdkDeviceManager" title="GdkDeviceManager"><span class="type">GdkDeviceManager</span></a> *device_manager</code></em>,
                                                         <em class="parameter"><code><a class="link" href="gdk3-GdkDevice.html#GdkDeviceType" title="enum GdkDeviceType"><span class="type">GdkDeviceType</span></a> type</code></em>);
<a class="link" href="gdk3-GdkDevice.html#GdkDevice" title="GdkDevice"><span class="returnvalue">GdkDevice</span></a> *         <a class="link" href="gdk3-GdkDeviceManager.html#gdk-device-manager-get-client-pointer" title="gdk_device_manager_get_client_pointer ()">gdk_device_manager_get_client_pointer</a>
                                                        (<em class="parameter"><code><a class="link" href="gdk3-GdkDeviceManager.html#GdkDeviceManager" title="GdkDeviceManager"><span class="type">GdkDeviceManager</span></a> *device_manager</code></em>);
</pre>
</div>
<div class="refsect1">
<a name="gdk3-GdkDeviceManager.description"></a><h2>Description</h2>
<p>
In addition to a single pointer and keyboard for user interface input,
GDK contains support for a variety of input devices, including graphics
tablets, touchscreens and multiple pointers/keyboards interacting
simultaneously with the user interface. Under X, the support for multiple
input devices is done through the <em class="firstterm">XInput 2</em> extension,
which also supports additional features such as sub-pixel positioning
information and additional device-dependent information.
</p>
<p>
By default, and if the platform supports it, GDK is aware of multiple
keyboard/pointer pairs and multitouch devices, this behavior can be
changed by calling <a class="link" href="gdk3-GdkDeviceManager.html#gdk-disable-multidevice" title="gdk_disable_multidevice ()"><code class="function">gdk_disable_multidevice()</code></a> before <a class="link" href="gdk3-GdkDisplay.html#gdk-display-open" title="gdk_display_open ()"><code class="function">gdk_display_open()</code></a>,
although there would rarely be a reason to do that. For a widget or
window to be dealt as multipointer aware,
<a class="link" href="gdk3-Windows.html#gdk-window-set-support-multidevice" title="gdk_window_set_support_multidevice ()"><code class="function">gdk_window_set_support_multidevice()</code></a> or
<code class="function">gtk_widget_set_support_multidevice()</code> must have been called on it.
</p>
<p>
Conceptually, in multidevice mode there are 2 device types. Virtual
devices (or master devices) are represented by the pointer cursors
and keyboard foci that are seen on the screen. Physical devices (or
slave devices) represent the hardware that is controlling the virtual
devices, and thus have no visible cursor on the screen.
</p>
<p>
Virtual devices are always paired, so there is a keyboard device for every
pointer device. Associations between devices may be inspected through
<a class="link" href="gdk3-GdkDevice.html#gdk-device-get-associated-device" title="gdk_device_get_associated_device ()"><code class="function">gdk_device_get_associated_device()</code></a>.
</p>
<p>
There may be several virtual devices, and several physical devices could
be controlling each of these virtual devices. Physical devices may also
be "floating", which means they are not attached to any virtual device.
</p>
<p>
By default, GDK will automatically listen for events coming from all
master devices, setting the <a class="link" href="gdk3-GdkDevice.html#GdkDevice" title="GdkDevice"><span class="type">GdkDevice</span></a> for all events coming from input
devices,
<sup>[<a name="id2949879" href="#ftn.id2949879" class="footnote">1</a>]</sup>
Although <a class="link" href="gdk3-Windows.html#gdk-window-set-support-multidevice" title="gdk_window_set_support_multidevice ()"><code class="function">gdk_window_set_support_multidevice()</code></a> must be called on
<a href="gdk3-Windows.html#GdkWindow"><span class="type">GdkWindows</span></a> in order to support additional features of multiple pointer
interaction, such as multiple per-device enter/leave events, the default
setting will emit just one enter/leave event pair for all devices on the
window. See <a class="link" href="gdk3-Windows.html#gdk-window-set-support-multidevice" title="gdk_window_set_support_multidevice ()"><code class="function">gdk_window_set_support_multidevice()</code></a> documentation for more
information.
</p>
<p>
In order to listen for events coming from other than a virtual device,
<a class="link" href="gdk3-Windows.html#gdk-window-set-device-events" title="gdk_window_set_device_events ()"><code class="function">gdk_window_set_device_events()</code></a> must be called. Generally, this function
can be used to modify the event mask for any given device.
</p>
<p>
Input devices may also provide additional information besides X/Y.
For example, graphics tablets may also provide pressure and X/Y tilt
information. This information is device-dependent, and may be
queried through <a class="link" href="gdk3-GdkDevice.html#gdk-device-get-axis" title="gdk_device_get_axis ()"><code class="function">gdk_device_get_axis()</code></a>. In multidevice mode, virtual
devices will change axes in order to always represent the physical
device that is routing events through it. Whenever the physical device
changes, the <span class="type">"n-axes"</span> property will be notified, and
<a class="link" href="gdk3-GdkDevice.html#gdk-device-list-axes" title="gdk_device_list_axes ()"><code class="function">gdk_device_list_axes()</code></a> will return the new device axes.
</p>
<p>
Devices may also have associated <em class="firstterm">keys</em> or
macro buttons. Such keys can be globally set to map into normal X
keyboard events. The mapping is set using <a class="link" href="gdk3-GdkDevice.html#gdk-device-set-key" title="gdk_device_set_key ()"><code class="function">gdk_device_set_key()</code></a>.
</p>
<p>
In order to query the device hierarchy and be aware of changes in the
device hierarchy (such as virtual devices being created or removed, or
physical devices being plugged or unplugged), GDK provides
<a class="link" href="gdk3-GdkDeviceManager.html#GdkDeviceManager" title="GdkDeviceManager"><span class="type">GdkDeviceManager</span></a>. On X11, multidevice support is implemented through
XInput 2. Unless <a class="link" href="gdk3-GdkDeviceManager.html#gdk-disable-multidevice" title="gdk_disable_multidevice ()"><code class="function">gdk_disable_multidevice()</code></a> is called, the XInput 2.x
<a class="link" href="gdk3-GdkDeviceManager.html#GdkDeviceManager" title="GdkDeviceManager"><span class="type">GdkDeviceManager</span></a> implementation will be used as the input source. Otherwise
either the core or XInput 1.x implementations will be used.
</p>
</div>
<div class="refsect1">
<a name="gdk3-GdkDeviceManager.details"></a><h2>Details</h2>
<div class="refsect2">
<a name="GdkDeviceManager"></a><h3>GdkDeviceManager</h3>
<pre class="programlisting">typedef struct {
  GObject parent_instance;
} GdkDeviceManager;
</pre>
<p>
</p>
</div>
<hr>
<div class="refsect2">
<a name="gdk-disable-multidevice"></a><h3>gdk_disable_multidevice ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span>                gdk_disable_multidevice             (<em class="parameter"><code><span class="type">void</span></code></em>);</pre>
<p>
Disables multidevice support in GDK. This call must happen prior
to <a class="link" href="gdk3-GdkDisplay.html#gdk-display-open" title="gdk_display_open ()"><code class="function">gdk_display_open()</code></a>, <code class="function">gtk_init()</code>, <code class="function">gtk_init_with_args()</code> or
<code class="function">gtk_init_check()</code> in order to take effect.
</p>
<p>
Most common GTK+ applications won't ever need to call this. Only
applications that do mixed GDK/Xlib calls could want to disable
multidevice support if such Xlib code deals with input devices in
any way and doesn't observe the presence of XInput 2.
</p>
<p class="since">Since 3.0</p>
</div>
<hr>
<div class="refsect2">
<a name="gdk-device-manager-get-display"></a><h3>gdk_device_manager_get_display ()</h3>
<pre class="programlisting"><a class="link" href="gdk3-GdkDisplay.html#GdkDisplay" title="GdkDisplay"><span class="returnvalue">GdkDisplay</span></a> *        gdk_device_manager_get_display      (<em class="parameter"><code><a class="link" href="gdk3-GdkDeviceManager.html#GdkDeviceManager" title="GdkDeviceManager"><span class="type">GdkDeviceManager</span></a> *device_manager</code></em>);</pre>
<p>
Gets the <a class="link" href="gdk3-GdkDisplay.html#GdkDisplay" title="GdkDisplay"><span class="type">GdkDisplay</span></a> associated to <em class="parameter"><code>device_manager</code></em>.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>device_manager</code></em> :</span></p></td>
<td>a <a class="link" href="gdk3-GdkDeviceManager.html#GdkDeviceManager" title="GdkDeviceManager"><span class="type">GdkDeviceManager</span></a>
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>the <a class="link" href="gdk3-GdkDisplay.html#GdkDisplay" title="GdkDisplay"><span class="type">GdkDisplay</span></a> to which <em class="parameter"><code>device_manager</code></em> is
associated to, or <a href="../glib/glib-Standard-Macros.html#NULL:CAPS"><span class="type">NULL</span></a>. This memory is owned by GDK and
must not be freed or unreferenced. <span class="annotation">[<acronym title="Don't free data after the code is done."><span class="acronym">transfer none</span></acronym>]</span>
</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 3.0</p>
</div>
<hr>
<div class="refsect2">
<a name="gdk-device-manager-list-devices"></a><h3>gdk_device_manager_list_devices ()</h3>
<pre class="programlisting"><a href="../glib/glib-Doubly-Linked-Lists.html#GList"><span class="returnvalue">GList</span></a> *             gdk_device_manager_list_devices     (<em class="parameter"><code><a class="link" href="gdk3-GdkDeviceManager.html#GdkDeviceManager" title="GdkDeviceManager"><span class="type">GdkDeviceManager</span></a> *device_manager</code></em>,
                                                         <em class="parameter"><code><a class="link" href="gdk3-GdkDevice.html#GdkDeviceType" title="enum GdkDeviceType"><span class="type">GdkDeviceType</span></a> type</code></em>);</pre>
<p>
Returns the list of devices of type <em class="parameter"><code>type</code></em> currently attached to
<em class="parameter"><code>device_manager</code></em>.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>device_manager</code></em> :</span></p></td>
<td>a <a class="link" href="gdk3-GdkDeviceManager.html#GdkDeviceManager" title="GdkDeviceManager"><span class="type">GdkDeviceManager</span></a>
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>type</code></em> :</span></p></td>
<td>device type to get.</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>a list of
<a class="link" href="gdk3-GdkDevice.html#GdkDevice" title="GdkDevice"><span class="type">GdkDevice</span></a>s. The returned list must be
freed with <a href="../glib/glib-Doubly-Linked-Lists.html#g-list-free"><code class="function">g_list_free()</code></a>. The list elements are owned by
GTK+ and must not be freed or unreffed. <span class="annotation">[<acronym title="Free data container after the code is done."><span class="acronym">transfer container</span></acronym>][<acronym title="Generics and defining elements of containers and arrays."><span class="acronym">element-type</span></acronym> Gdk.Device]</span>
</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 3.0</p>
</div>
<hr>
<div class="refsect2">
<a name="gdk-device-manager-get-client-pointer"></a><h3>gdk_device_manager_get_client_pointer ()</h3>
<pre class="programlisting"><a class="link" href="gdk3-GdkDevice.html#GdkDevice" title="GdkDevice"><span class="returnvalue">GdkDevice</span></a> *         gdk_device_manager_get_client_pointer
                                                        (<em class="parameter"><code><a class="link" href="gdk3-GdkDeviceManager.html#GdkDeviceManager" title="GdkDeviceManager"><span class="type">GdkDeviceManager</span></a> *device_manager</code></em>);</pre>
<p>
Returns the client pointer, that is, the master pointer that acts as the core pointer
for this application. In X11, window managers may change this depending on the interaction
pattern under the presence of several pointers.
</p>
<p>
You should use this function sheldomly, only in code that isn't triggered by a <a class="link" href="gdk3-Event-Structures.html#GdkEvent" title="union GdkEvent"><span class="type">GdkEvent</span></a>
and there aren't other means to get a meaningful <a class="link" href="gdk3-GdkDevice.html#GdkDevice" title="GdkDevice"><span class="type">GdkDevice</span></a> to operate on.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>device_manager</code></em> :</span></p></td>
<td>a <a class="link" href="gdk3-GdkDeviceManager.html#GdkDeviceManager" title="GdkDeviceManager"><span class="type">GdkDeviceManager</span></a>
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>The client pointer. This memory is
owned by GDK and must not be freed or unreferenced. <span class="annotation">[<acronym title="Don't free data after the code is done."><span class="acronym">transfer none</span></acronym>]</span>
</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 3.0</p>
</div>
</div>
<div class="refsect1">
<a name="gdk3-GdkDeviceManager.see-also"></a><h2>See Also</h2>
<a class="link" href="gdk3-GdkDevice.html#GdkDevice" title="GdkDevice"><span class="type">GdkDevice</span></a>, <a class="link" href="gdk3-Event-Structures.html#GdkEvent" title="union GdkEvent"><span class="type">GdkEvent</span></a>
</div>
<div class="footnotes">
<br><hr width="100" align="left">
<div class="footnote">
<a class="link" href="gdk3-Events.html#GDK-MOTION-NOTIFY:CAPS"><span class="type"><sup>[<a name="ftn.id2949879" href="#id2949879" class="link">1</a>] </sup>GDK_MOTION_NOTIFY</span></a><a class="link" href="gdk3-Events.html#GDK-BUTTON-PRESS:CAPS"><span class="type">GDK_BUTTON_PRESS</span></a><a class="link" href="gdk3-Events.html#GDK-2BUTTON-PRESS:CAPS"><span class="type">GDK_2BUTTON_PRESS</span></a><a class="link" href="gdk3-Events.html#GDK-3BUTTON-PRESS:CAPS"><span class="type">GDK_3BUTTON_PRESS</span></a><a class="link" href="gdk3-Events.html#GDK-BUTTON-RELEASE:CAPS"><span class="type">GDK_BUTTON_RELEASE</span></a><a class="link" href="gdk3-Events.html#GDK-SCROLL:CAPS"><span class="type">GDK_SCROLL</span></a><a class="link" href="gdk3-Events.html#GDK-KEY-PRESS:CAPS"><span class="type">GDK_KEY_PRESS</span></a><a class="link" href="gdk3-Events.html#GDK-KEY-RELEASE:CAPS"><span class="type">GDK_KEY_RELEASE</span></a><a class="link" href="gdk3-Events.html#GDK-ENTER-NOTIFY:CAPS"><span class="type">GDK_ENTER_NOTIFY</span></a><a class="link" href="gdk3-Events.html#GDK-LEAVE-NOTIFY:CAPS"><span class="type">GDK_LEAVE_NOTIFY</span></a><a class="link" href="gdk3-Events.html#GDK-FOCUS-CHANGE:CAPS"><span class="type">GDK_FOCUS_CHANGE</span></a><a class="link" href="gdk3-Events.html#GDK-PROXIMITY-IN:CAPS"><span class="type">GDK_PROXIMITY_IN</span></a><a class="link" href="gdk3-Events.html#GDK-PROXIMITY-OUT:CAPS"><span class="type">GDK_PROXIMITY_OUT</span></a><a class="link" href="gdk3-Events.html#GDK-DRAG-ENTER:CAPS"><span class="type">GDK_DRAG_ENTER</span></a><a class="link" href="gdk3-Events.html#GDK-DRAG-LEAVE:CAPS"><span class="type">GDK_DRAG_LEAVE</span></a><a class="link" href="gdk3-Events.html#GDK-DRAG-MOTION:CAPS"><span class="type">GDK_DRAG_MOTION</span></a><a class="link" href="gdk3-Events.html#GDK-DRAG-STATUS:CAPS"><span class="type">GDK_DRAG_STATUS</span></a><a class="link" href="gdk3-Events.html#GDK-DROP-START:CAPS"><span class="type">GDK_DROP_START</span></a><a class="link" href="gdk3-Events.html#GDK-DROP-FINISHED:CAPS"><span class="type">GDK_DROP_FINISHED</span></a><a class="link" href="gdk3-Events.html#GDK-GRAB-BROKEN:CAPS"><span class="type">GDK_GRAB_BROKEN</span></a>
</div>
</div>
</div>
<div class="footer">
<hr>
          Generated by GTK-Doc V1.17</div>
</body>
</html>